package org.nepu.scr.indexrate.converter.drillingrate.keydevice.circulationsystem;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.drillingrate.keydevice.circulationsystem.Circulation;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class CirculationConverter implements AttributeConverter<Circulation, String> {
    @Override
    public String convertToDatabaseColumn(Circulation circulation) {
        return JSONUtil.toJsonStr(circulation);
    }

    @Override
    public Circulation convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, Circulation.class);
    }
}
